#ifndef _CONSOLE_H
#define _CONSOLE_H 

#include <list.h>

#define MAJOR_CONSOLE	(1)		

#define CONSOLE_FLAGS_ENABLED	(0x1)
#define CONSOLE_FLAGS_INPUT		(0x2)
#define CONSOLE_FLAGS_MASK		(0x3)

#define console_flags_is_enabled(flags)		((flags) & CONSOLE_FLAGS_ENABLED)
#define console_flags_is_disabled(flags)	(((flags) & CONSOLE_FLAGS_ENABLED) == 0)
#define console_flags_is_input(flags)		((flags) & CONSOLE_FLAGS_INPUT)

#define console_flags_set_enabled(flags)	((flags) |= CONSOLE_FLAGS_ENABLED)
#define console_flags_set_disabled(flags)	((flags) &= ~CONSOLE_FLAGS_ENABLED)
#define console_flags_set_input(flags)		((flags) |= CONSOLE_FLAGS_INPUT)

#define console_flags_clr_input(flags)		((flags) &= ~CONSOLE_FLAGS_INPUT)

struct console {
	unsigned int flags;
	struct device *real_dev;
	struct device *dev;
	struct list_head n_console_list;
};

struct console_driver {
	struct driver *drv;
};

#define device_to_console(dev)			((dev)->priv)
#define driver_to_console_driver(drv)	((drv)->priv)
#define console_to_device(con)			((con)->dev)
#define console_driver_to_driver(cdrv)	((cdrv)->drv)

int console_register(struct console *con);
int console_unregister(struct console *con);
int console_enable(struct console *con);
int console_disable(struct console *con);
int console_set_input(struct console *con);
int console_open(void);
void console_close(void);
void console_flush(void);
int console_write(const char *buf, unsigned int count);
int console_read(char *buf, unsigned int count);

#endif /* _CONSOLE_H */

